/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * RegistroDactilar1.java
 *
 * Created on 20-09-2010, 10:49:47 AM
 */

package INTERFAZ;


import CONTROLES.SeleccionDactilar;
import MODELOS.Cliente;
import UTILITARIOS.Herramienta;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.event.WindowAdapter;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.BevelBorder;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;


/**
 *
 * @author respaldo
 */
public class RegistroDactilar1 extends javax.swing.JFrame {
    private ArrayList<SeleccionDactilar> seleccion=new ArrayList<SeleccionDactilar>();
    public Cliente idUsuarioARegistrar;
    public String ruta;
    


   


    /** Creates new form RegistroDactilar1 */
    public RegistroDactilar1(Cliente c, String ruta) {
        this.idUsuarioARegistrar = c;
        this.ruta = ruta;
        setAlwaysOnTop(true);
        
        initComponents();
        setSize(660, 400);
        setBackground(Color.BLACK);
        initImages();
        
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        chk_i_meñique = new javax.swing.JCheckBox();
        chk_i_anular = new javax.swing.JCheckBox();
        chk_i_medio = new javax.swing.JCheckBox();
        chk_i_indice = new javax.swing.JCheckBox();
        chk_i_pulgar = new javax.swing.JCheckBox();
        lbl_mano_izqui = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        lbl_mano_derech = new javax.swing.JLabel();
        chk_d_anular1 = new javax.swing.JCheckBox();
        chk_d_medio1 = new javax.swing.JCheckBox();
        chk_d_pulgar1 = new javax.swing.JCheckBox();
        chk_d_indice1 = new javax.swing.JCheckBox();
        chk_d_meñique1 = new javax.swing.JCheckBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Selección de dedos");
        setAlwaysOnTop(true);
        setBackground(new java.awt.Color(0, 0, 0));
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setLabel("SIGUIENTE");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(238, 238, 238));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Mano Izquierda", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));
        jPanel1.setPreferredSize(new java.awt.Dimension(285, 236));

        chk_i_meñique.setBackground(new java.awt.Color(238, 238, 238));
        chk_i_meñique.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        chk_i_meñique.setLabel("Meñique");

        chk_i_anular.setBackground(new java.awt.Color(238, 238, 238));
        chk_i_anular.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        chk_i_anular.setLabel("Anular");

        chk_i_medio.setBackground(new java.awt.Color(238, 238, 238));
        chk_i_medio.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        chk_i_medio.setLabel("Medio");

        chk_i_indice.setBackground(new java.awt.Color(238, 238, 238));
        chk_i_indice.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        chk_i_indice.setLabel("Indice");

        chk_i_pulgar.setBackground(new java.awt.Color(238, 238, 238));
        chk_i_pulgar.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        chk_i_pulgar.setLabel("Pulgar");

        lbl_mano_izqui.setText("jLabel1");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lbl_mano_izqui, javax.swing.GroupLayout.DEFAULT_SIZE, 208, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(chk_i_anular, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)
                    .addComponent(chk_i_medio, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(chk_i_indice, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(chk_i_pulgar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(chk_i_meñique, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(chk_i_meñique, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chk_i_anular, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chk_i_medio, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chk_i_indice, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chk_i_pulgar, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)
                .addGap(145, 145, 145))
            .addComponent(lbl_mano_izqui, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
        );

        jPanel2.setBackground(new java.awt.Color(238, 238, 238));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Mano Derecha", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));
        jPanel2.setPreferredSize(new java.awt.Dimension(285, 236));

        lbl_mano_derech.setText("jLabel1");

        chk_d_anular1.setBackground(new java.awt.Color(238, 238, 238));
        chk_d_anular1.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        chk_d_anular1.setLabel("Anular");

        chk_d_medio1.setBackground(new java.awt.Color(238, 238, 238));
        chk_d_medio1.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        chk_d_medio1.setLabel("Medio");

        chk_d_pulgar1.setBackground(new java.awt.Color(238, 238, 238));
        chk_d_pulgar1.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        chk_d_pulgar1.setLabel("Pulgar");

        chk_d_indice1.setBackground(new java.awt.Color(238, 238, 238));
        chk_d_indice1.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        chk_d_indice1.setLabel("Indice");

        chk_d_meñique1.setBackground(new java.awt.Color(238, 238, 238));
        chk_d_meñique1.setFont(new java.awt.Font("DejaVu Sans", 0, 10));
        chk_d_meñique1.setLabel("Meñique");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(chk_d_pulgar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(chk_d_indice1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(chk_d_medio1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(chk_d_anular1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(chk_d_meñique1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbl_mano_derech, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(chk_d_meñique1, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chk_d_anular1, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chk_d_medio1, javax.swing.GroupLayout.DEFAULT_SIZE, 35, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chk_d_indice1, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chk_d_pulgar1, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)
                .addGap(146, 146, 146))
            .addComponent(lbl_mano_derech, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
                        .addGap(18, 18, 18)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 297, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(251, 251, 251))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jButton1.getAccessibleContext().setAccessibleName("siguiente");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        if(seleccionBacia()){
           
            JOptionPane.showMessageDialog(this, "No se selecciono ningún dedo\npara el registro biométrico.\nSeleccione por lo menos una opción.", "Advertencia", JOptionPane.OK_OPTION);
           
            
        }
        else{
            procesarInformacionObtenida();
            setVisible(false);
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
       JOptionPane.showMessageDialog(this, "No se selecciono ningún dedo\npara el registro biométrico.\nSeleccione por lo menos una opción.", "Advertencia", JOptionPane.OK_OPTION);
       this.setVisible(true);
    }//GEN-LAST:event_formWindowClosing

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                //new RegistroDactilar1().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox chk_d_anular1;
    private javax.swing.JCheckBox chk_d_indice1;
    private javax.swing.JCheckBox chk_d_medio1;
    private javax.swing.JCheckBox chk_d_meñique1;
    private javax.swing.JCheckBox chk_d_pulgar1;
    private javax.swing.JCheckBox chk_i_anular;
    private javax.swing.JCheckBox chk_i_indice;
    private javax.swing.JCheckBox chk_i_medio;
    private javax.swing.JCheckBox chk_i_meñique;
    private javax.swing.JCheckBox chk_i_pulgar;
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JLabel lbl_mano_derech;
    private javax.swing.JLabel lbl_mano_izqui;
    // End of variables declaration//GEN-END:variables

    private void initImages() {
        ImageIcon im1=new ImageIcon(getClass().getResource("/imagenes/i_mano.jpg"));
        ImageIcon im2=new ImageIcon(getClass().getResource("/imagenes/d_mano.jpg"));

        lbl_mano_derech.setText("");lbl_mano_izqui.setText("");

        ImageIcon img_izq=new ImageIcon(im1.getImage().getScaledInstance(200    ,288, 1));
        ImageIcon img_der=new ImageIcon(im2.getImage().getScaledInstance(200, 288, 1));

        lbl_mano_izqui.setIcon(img_izq);
        lbl_mano_derech.setIcon(img_der);
        
    }

    private boolean seleccionBacia() {
        boolean resp=chk_d_anular1.isSelected()||chk_d_indice1.isSelected()||chk_d_medio1.isSelected()||
                chk_d_meñique1.isSelected()||chk_d_pulgar1.isSelected()||chk_i_anular.isSelected()||chk_i_indice.isSelected()
                ||chk_i_medio.isSelected()||chk_i_meñique.isSelected()||chk_i_pulgar.isSelected();

        return !resp;
    }

    private void procesarInformacionObtenida() {
        //dedos meñiques
        if(chk_d_meñique1.isSelected()){
            SeleccionDactilar s=new SeleccionDactilar();
            s.setMensaje("Ingrese el dedo meñique de la mano derecha");
            //s.setImagenReferencia("d_menique.jpg");
            s.setMANO("Derecha");s.setDEDO("Menique");
            seleccion.add(s);
        }
        if(chk_i_meñique.isSelected()){
            SeleccionDactilar s=new SeleccionDactilar();
            s.setMensaje("Ingrese el dedo meñique de la mano izquierda");
            //s.setImagenReferencia("i_menique.jpg");
            s.setMANO("Izquierda");s.setDEDO("Menique");
            seleccion.add(s);
        }
        //dedos anular
        if(chk_d_anular1.isSelected()){
            SeleccionDactilar s=new SeleccionDactilar();
            s.setMensaje("Ingrese el dedo anular de la mano derecha");
            //s.setImagenReferencia("d_anular.jpg");
            s.setMANO("Derecha");s.setDEDO("Anular");
            seleccion.add(s);
        }
        if(chk_i_anular.isSelected()){
            SeleccionDactilar s=new SeleccionDactilar();
            s.setMensaje("Ingrese el dedo anular de la mano izquierda");
            //s.setImagenReferencia("i_anular.jpg");
            s.setMANO("Izquierda");s.setDEDO("Anular");
            seleccion.add(s);
        }
        //dedos medio
        if(chk_d_medio1.isSelected()){
            SeleccionDactilar s=new SeleccionDactilar();
            s.setMensaje("Ingrese el dedo medio de la mano derecha");
            //s.setImagenReferencia("d_medio.jpg");
            s.setMANO("Derecha");s.setDEDO("Medio");
            seleccion.add(s);
        }
        if(chk_i_medio.isSelected()){
            SeleccionDactilar s=new SeleccionDactilar();
            s.setMensaje("Ingrese el dedo medio de la mano izquierda");
            //s.setImagenReferencia("i_medio.jpg");
            s.setMANO("Izquierda");s.setDEDO("Medio");
            seleccion.add(s);
        }
        //dedos indice
        if(chk_d_indice1.isSelected()){
            SeleccionDactilar s=new SeleccionDactilar();
            s.setMensaje("Ingrese el dedo índice de la mano derecha");
            //s.setImagenReferencia("d_indice.jpg");
            s.setMANO("Derecha");s.setDEDO("Indice");
            seleccion.add(s);
        }
        if(chk_i_indice.isSelected()){
            SeleccionDactilar s=new SeleccionDactilar();
            s.setMensaje("Ingrese el dedo índice de la mano izquierda");
            //s.setImagenReferencia("i_indice.jpg");
            s.setMANO("Izquierda");s.setDEDO("Indice");
            seleccion.add(s);
        }
        //dedos pulgares
        if(chk_d_pulgar1.isSelected()){
            SeleccionDactilar s=new SeleccionDactilar();
            s.setMensaje("Ingrese el dedo pulgar de la mano derecha");
            //s.setImagenReferencia("d_pulgar.jpg");
            s.setMANO("Derecha"); s.setDEDO("Pulgar");
            seleccion.add(s);
        }
        if(chk_i_pulgar.isSelected()){
            SeleccionDactilar s=new SeleccionDactilar();
            s.setMensaje("Ingrese el dedo pulgar de la mano izquierda");
            //s.setImagenReferencia("i_pulgar.jpg");
             s.setMANO("Izquierda"); s.setDEDO("Pulgar");
            seleccion.add(s);
        }

        comenzarLecturaDehuellas();

    }

        
    private void comenzarLecturaDehuellas() {
        RegistroDactilarFrame registroFrame=new RegistroDactilarFrame();
        registroFrame.setIdClienteARegistrar(idUsuarioARegistrar);
        registroFrame.setRuta(ruta);
        registroFrame.setParent(this);
        registroFrame.setSeleccion(seleccion);
        registroFrame.pack();
        Herramienta.centerOnScreen(registroFrame);

        registroFrame.setVisible(true);
        registroFrame.setAlwaysOnTop(true);

       
    }

    

    
}
